﻿
using Dapper;
using HBase;
 
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Transactions;

namespace hCommand
{
    /**
   *┌────────────────────────────────────────────────┐
   *│　描    述：Component                                                    
   *│　作    者：sgj                                              
   *│　版    本：1.0                                              
   *│　创建时间：2020/9/2 11:28:16                        
   *└────────────────────────────────────────────────┘
   **/
    public  class StockDeleteEngine<CS> : AbsLocEngine where CS : AbsCoreStock {
        public long stockId;
   
       
        protected override TransRes Execute(IDbConnection conn ,IDbTransaction tran) {

            CS cs = conn.GetById<CS>(stockId, tran);
            if (cs == null) {
                return new TransRes(stockId + "不存在!");

            }

            if (cs.status == (int)StockStatus.盘库中|| cs.status == (int)StockStatus.移动中) {
                return new TransRes(stockId + "操作中不能删除!");

            }

            cs.changeTime = DateTime.Now;
            cs.status = (int)StockStatus.删除;
            int locId = cs.locId;
            cs.locId = -1;
            conn.Update(cs, tran); 

            UpdataWhLoc(conn, tran, locId, 0);
            return afterIntask(conn, tran, cs,locId);
        }


        protected virtual TransRes afterIntask(IDbConnection conn, IDbTransaction trans, CS cs,int oldLoc) {
            return new TransRes();
        }
    }
}
